<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/common/common-css.jsp" %>
<script>
		cmdEdit  = "/edit/editPage.action";
</script>
<style>
		#jquery-table td{cursor:pointer !important}
		.load_bg{background:#000;opacity:0.1;left:0px;top:0px;position:fixed;height:100%;width:100%;overflow:hidden;z-index:10000;}
		.load_img{left:50%;top:180px;position:fixed;height:50px;overflow:hidden;z-index:20000;}
		</style>
	</head>
<body  class="no-skin">

<div  class="load_bg" style="display:none"></div>
<img src="http://img.xmiles.cn/commentloading.gif" class="load_img" style="display:none"/>
	<div class="page-content">
				<form id="queryForm" action="" method="POST">
					<div class="page-content-area">
						<div class="row">
							 <div class="col-sm-12">
								<div class="widget-box" style="border:0px solid #ccc; border-top:none;border-bottom:none;margin-top:15px;">
								<hr style="margin-top:0px;margin-bottom:0x">
								<div class="widget-header widget-header-blue widget-header-flat">
										<h4 class="widget-title">选择条件进行查询</h4>
										<div class="widget-toolbar">
											<a href="#" data-action="collapse">
												<i class="ace-icon fa fa-chevron-up"></i>
											</a>
										</div>
								</div>
									
							<div class=" widget-body">
								<div class="widget-main " >
								
									<!-- 根据消息内容查询 -->	
									<div class="form-group col-xs-12 col-sm-4">
								        <label class="col-sm-4 control-label" style="text-align:right" for="userPhone">消息内容:</label>
								        <div class="col-sm-4">
								            <input type="text" class="input-sm form-control" style="padding-left:0px" name="lockkey" > 
								        </div>
									</div>
									<!-- 根据推送内容查询 -->	
									<div class="form-group col-xs-12 col-sm-4">
								        <label class="col-sm-4 control-label" style="text-align:right" for="userPhone">推送内容:</label>
								        <div class="col-sm-4">
								            <input type="text" class="input-sm form-control" style="padding-left:0px" name="content" > 
								        </div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4">
								        <label class="col-sm-4 control-label" style="text-align:right" for="userPhone">推送平台:</label>
								        <div class="col-sm-4">
								            <input type="text" class="input-sm form-control" style="padding-left:0px" name="platfrom" > 
								        </div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4">
								        <label class="col-sm-4 control-label" style="text-align:right" for="userPhone">推送状态:</label>
								        <div class="col-sm-4">
								            <input type="text" class="input-sm form-control" style="padding-left:0px" name="status" > 
								        </div>
									</div>
								
								
								
														<!--  根据时间查询   -->
														<div class="form-group col-xs-12 col-sm-4 ">
						                                		<label class="col-sm-4 control-label" style="text-align:right" for="time">创建时间:</label>
							                                    <div class="col-sm-4">
							                                        <div class="input-daterange input-group">
							                                            <input id="timeStart" type="text" class="date-picker form-control"
							                                                   data-date-format="yyyy-mm-dd" style="padding-left:0"
							                                                   name="createtime_start" id="time" >
							                                        </div>
							                                    </div>
							                                    <div class="col-sm-4">
							                                        <div class="input-daterange input-group">
							                                            <input id="timeEnd" type="text" class="date-picker form-control"
							                                                   data-date-format="yyyy-mm-dd" style="padding-left:0"
							                                                   name="createtime_end" id="time" >
							                                        </div>
							                                    </div>
						                               	</div>
						                               										
														<!--  根据时间查询   -->
														<div class="form-group col-xs-12 col-sm-4 ">
						                                		<label class="col-sm-4 control-label" style="text-align:right" for="time">推送时间:</label>
							                                    <div class="col-sm-4">
							                                        <div class="input-daterange input-group">
							                                            <input id="timeStart" type="text" class="date-picker form-control"
							                                                   data-date-format="yyyy-mm-dd" style="padding-left:0"
							                                                   name="pushtime_start" id="time" >
							                                        </div>
							                                    </div>
							                                    <div class="col-sm-4">
							                                        <div class="input-daterange input-group">
							                                            <input id="timeEnd" type="text" class="date-picker form-control"
							                                                   data-date-format="yyyy-mm-dd" style="padding-left:0"
							                                                   name="pushtime_end" id="time" >
							                                        </div>
							                                    </div>
						                               	</div>
														
														
												</div><!-- /.widget-main -->
										</div><!-- /.widget-body -->
								</div><!-- /.widget-box -->
							</div><!-- /.col-sm-12 -->
								<div class="col-md-12 center">
									 <div class="clearfix">
												<button class="btn btn-purple  no-border" type="button" name="btn-query" onclick="query_any()">
													<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
													查询
												</button>
												&nbsp;&nbsp;&nbsp;
												<button class="btn btn-grey  no-border" type="reset">
													<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
													重置
												</button>
									  </div>
								</div>
						</div><!-- /.row -->
								 
						<hr style="display:none;" id="delete_hr">
						<div class="row">
								<div class="col-xs-12">
									<table id="jquery-table" class="table table-striped table-bordered table-hover"></table>
								</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content-area -->
				</form>
			</div><!-- /.page-content -->
				
	<%@ include file="/common/common-js.jsp" %>
	
		<!-- inline scripts related to this page -->
	
	<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
	<script type="text/javascript">
	
		//【查询】按钮Click事件
		function query_any() {

			$("#export").show();
			$(".load_bg").removeAttr("style");
			$(".load_img").removeAttr("style");
			if (jqTable != null) {
				jqTable.fnDraw();
			} else {
				loaddata();
			}
			$("#delete_hr").removeAttr("style");
			$("#delete_hr").attr("style",
					"margin-top:0px;margin-bottom:20px;display:block");
		}

		var jqTable = null;
		var loaddata = function() {
			jQuery(function($) {
				jqTable = $('#jquery-table').dataTable(
						{
							//数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
							"columnDefs" : [

							{
								"title" : "推送ID",
								"name" : "pushid",
								"data" : "pushid",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 0 ],
								"bSortable" : false
							},
							{
								"title" : "创建时间",
								"name" : "createtime",
								"data" : "createtime",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 1 ],
								"bSortable" : false
							},
							{
								"title" : "推送时间",
								"name" : "sendtime",
								"data" : "sendtime",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 2 ],
								"bSortable" : false
							},
							{
								"title" : "推送内容",
								"name" : "content",
								"data" : "content",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 3 ],
								"bSortable" : false
							},
							{
								"title" : "安卓推送消息",
								"name" : "android_content",
								"data" : "android_content",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 4 ],
								"bSortable" : false,
								"render":function(data, type, row){
			                    	switch (data) {
				                    	case "":
				                            return '--';
				                        case null:
				                            return '--';
				                        default:
			                                return data;
			                    	}
			                    }
							},
							{
								"title" : "ios推送消息",
								"name" : "ios_content",
								"data" : "ios_content",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 5 ],
								"bSortable" : false,
								"render":function(data, type, row){
			                    	switch (data) {
				                    	case "":
				                            return '--';
				                        case null:
				                            return '--';
				                        case "null":
				                            return '--';
				                        default:
			                                return data;
			                    	}
			                    }
							},
							{
								"title" : "推送平台",
								"name" : "platfrom",
								"data" : "platfrom",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 6 ],
								"bSortable" : false
							},
							{
								"title" : "产品",
								"name" : "task_sendproduct",
								"data" : "task_sendproduct",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 7 ],
								"bSortable" : false
							},
							
							{
								"title" : "推送状态",
								"name" : "status",
								"data" : "status",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 8 ],
								"bSortable" : false
							},
							{
								"title" : "创建人",
								"name" : "createid",
								"data" : "createid",
								"width" : "5%",
								"class" : "center",
								"targets" : [ 9 ],
								"bSortable" : false
							},
							{
								"title" : "操作",
							    "data": "op",
							    "class": "center",
							    "width": "5%", 
								"targets" : [ 10 ],
								"bSortable" : false,
								"render": function(value, type, row) {
									if (row.status=="已发送") {
										var temp =  "<input class='btn btn-success btn-sm' type='button' name='PK' value='删除' onclick='delete_("+ row.id +")'/>";
									} else {
					    	  		var temp = "<input class='btn btn-success btn-sm' type='button' name='PK' value='编辑' onclick='edit("+ row.id +")'/>&nbsp;&nbsp;" + 
					    	  				   "<input class='btn btn-success btn-sm' type='button' name='PK' value='删除' onclick='delete_("+ row.id +")'/>";
									}
	                         		return temp;
				    	  	  }
							}
							
						],
							"sAjaxSource" : ctx + "/pushmanage/querylist.action",//数据源URL
							"fnServerData" : function(sSource, aoData, fnCallback) {//从服务器请求数据
								var data = $('#queryForm').serializeObject();
								data.aoData = JSON.stringify(aoData);
								$.ajax({
									"dataType" : 'json',
									"type" : "POST",
									"url" : sSource,
									"data" : data,
									"success" : function(resp) {
										fnCallback(resp);
										initListPage();
										$(".load_bg").attr("style", "display:none");
										$(".load_img").attr("style", "display:none");
									},
									"error" : function(XMLHttpRequest,
											textStatus, errorThrown) {
										$(".load_bg").attr("style",
												"display:none");
										$(".load_img").attr("style",
												"display:none");
										alert('请求服务器错误,请刷新重试！！');
									},
								});
							},
							"sScrollXInner" : "100%",
							"sScrollY" : "100%",//如果不设置，IE会有问题
							"aaSorting" : [ [ 1, "desc" ] ]
						//初始化加载，默认按第几列排序、排序方式（列从0开始计算）
						});

			});
		}
 		jQuery(function() {
			$(".date-picker").datepicker({
				autoclose : true
			}).next().on(ace.click_event, function() {
				$(this).prev().focus();
			});
			/* $("#coupon_channel").combobox(); */
		});
 		
		function edit(id){
			var titleinfo = "修改" ;
	
			openDialogWithRand("/pushmanage/editPage.action" + "?id=" + id,800,800,titleinfo,function (data){jqTable.fnDraw();});
		}
		
		
		function delete_(id){
			var data = {"id":id};
			$.ajax({
				//"dataType" : 'json',
				"type" : "POST",
				"url" : ctx + "/pushmanage/deleteRecord.action",
				"data" : data,
				"success" : function(resp) {
					alert('删除成功');
					jqTable.fnDraw();
					//query_any();
				},
				"error" : function(XMLHttpRequest, textStatus, errorThrown) {
					alert('请求服务器错误,请刷新重试！！');
				},
			});
		}
 		
	</script>
</body>
</html>
